One of the easiest challenges of PoliCTF 2015 and the first we solved. The challenge’s description pointed us to “haas.polictf.it 80”. Netcating in we found a Tower of Hanoi server:
Can we get an error? Let’s try ‘-1’:
Ah! Prolog, I knew there was a point to studying it back in college. Can we inject some code?
So we can inject commands. Next we googled for any and all Prolog commands that might be useful. ‘1),listing,write('hello'’ displays the entire prolog database, but there is nothing really useful there. Instead we can have a look at the files using: ‘1),directory_files({dir},X),write(X’, until we find the flag:
Now we know were the flag is we can print off the ascii:
Executing shell commands or even opening a shell would have been possible with Prologs ‘exec’ or ‘process_create’ commands, but that seemed like overkill in this situation.